<template>
  <div class="iframe-view-page">
    <Spin fix v-if="frameLoad"></Spin>
    <iframe v-if="reload" :src="src" frameborder="0" @load="loadIframe"></iframe>
  </div>
</template>

<script>
export default {
  name: 'IframeView',
  props: {
    src: {
      type: String
    },
    name: {
      type: String
    },
    finish: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      reload: true,
      frameLoad: true
    }
  },
  mounted () {
  },
  destroyed () {
    this.$emit('update:finish', false)
  },
  methods: {
    loadIframe () {
      this.$emit('update:finish', true)
      this.frameLoad = false
    },
    freshIframe () {
      this.reload = false
      this.frameLoad = true
      setTimeout(() => {
        this.reload = true
      }, 100)
    }
  }
}
</script>

<style lang="stylus" scoped>
.iframe-view-page
  width 100%
  height 100%
  position relative
  iframe
    width 100%
    height 100%
</style>
